Skip to content

Conversation

@Enselic
Copy link
Member

@Enselic Enselic commented Jan 2, 2026

Closes #150514

Merging this PR unblocks #150591 and that PR will also act as a regression test since the code in that PR does not build without this fix. We could add a temporary dummy eii item to std before that PR lands, but it does not seem worth the effort.

To be honest I don't fully understand why #[rustc_macro_transparency = "transparent"] works, all I know is that it works. Without it, we get > 800 errors that looks like this.

r? @jdonszelmann is maybe interested in reviewing? Of course feel free to re-roll if you don't have time right now though.

Tracking issues

@Enselic Enselic added the F-extern_item_impls `#![feature(extern_item_impls)]` label Jan 2, 2026
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 2, 2026
@rustbot
Copy link
Collaborator

rustbot commented Jan 2, 2026

jdonszelmann is currently at their maximum review capacity.
They may take a while to respond.

@Enselic

This comment was marked as outdated.

@rustbot rustbot added the T-libs Relevant to the library team, which will review and decide on the PR/issue. label Jan 2, 2026
@Enselic
Copy link
Member Author

Enselic commented Jan 2, 2026

Ok let's roll then:

r? compiler

@rustbot rustbot assigned lcnr and unassigned Mark-Simulacrum Jan 2, 2026
@Enselic Enselic added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 2, 2026
@Enselic Enselic marked this pull request as draft January 2, 2026 12:39
@Enselic Enselic marked this pull request as ready for review January 2, 2026 16:44
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jan 2, 2026
@Enselic
Copy link
Member Author

Enselic commented Jan 2, 2026

@rustbot ready

@jdonszelmann
Copy link
Contributor

I'll do it anyway, reached cap because of the holidays
r? jdonszelmann

@rustbot rustbot assigned jdonszelmann and unassigned lcnr Jan 6, 2026
@jdonszelmann
Copy link
Contributor

So I think what's going on here is that in std, all items must have a stability attribute. And since we generate a bunch of extra items, their stability attributes match. I remember leaving a FIXME somewhere even that we have to forward more attributes. However, I'd like to be somewhat systematic about that. Making sure we forward all the right attributes to the right items, not just stability.

I'm not sure I understand the transparency attributes entirely correctly, but I think stability is tracked through spans and as such, the spans generated by the macro expansion affect the stability of the items. I think the real solution is to forward stability attributes themselves?

@jdonszelmann
Copy link
Contributor

I could be wrong there, maybe you've tried that

@jdonszelmann
Copy link
Contributor

(oh, sent you a message on zulip btw)

@jdonszelmann
Copy link
Contributor

@rustbot author

@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 7, 2026
@rustbot rustbot added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jan 7, 2026
@rust-bors
Copy link
Contributor

rust-bors bot commented Jan 10, 2026

☔ The latest upstream changes (presumably #150900) made this pull request unmergeable. Please resolve the merge conflicts.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jan 10, 2026
compiler: Forward attributes to eii-expanded macros

Since rust-lang#150592 is quite complicated to reason about I figured it would be good to split it up in smaller pieces that are easier to digest. Here is the attribute fix in isolation.

## The Problem

With this eii in **library/std/src/io/mod.rs**:
```rs
/// Foo
#[eii(on_broken_pipe)]
#[unstable(feature = "on_broken_pipe", issue = "150588")]
pub fn on_broken_pipe() -> OnBrokenPipe {
    OnBrokenPipe::BackwardsCompatible
}
```

you currently get this compilation error:

```
error: attribute macro has missing stability attribute
    --> library/std/src/io/mod.rs:2269:1
     |
2269 | #[eii(on_broken_pipe)]
     | ^^^^^^^^^^^^^^^^^^^^--
     | |
     | in this attribute macro expansion
     |
    ::: library/core/src/macros/mod.rs:1899:5
     |
1899 |     pub macro eii($item:item) {
     |     ------------- in this expansion of `#[eii]`
```

because with ` MAGIC_EXTRA_RUSTFLAGS=-Zunpretty=expanded ./x build library/std` we can see that a pub item in the expanded code is indeed missing that attribute:

```rs
const _: () =
    {
        #[on_broken_pipe]
        fn on_broken_pipe() -> OnBrokenPipe {
            OnBrokenPipe::BackwardsCompatible
        }
    };
unsafe extern "Rust" {
    /// Foo
    #[unstable(feature = "on_broken_pipe", issue = "150588")]
    #[rustc_eii_extern_item]
    pub safe fn on_broken_pipe()
    -> OnBrokenPipe;
}
#[rustc_builtin_macro(eii_shared_macro)]
#[eii_extern_target(on_broken_pipe)]
pub macro on_broken_pipe { () => {} }
```

## The Solution

With the fix, that error goes away because we get this expanded code instead:

```rs
const _: () =
    {
        #[on_broken_pipe]
        fn on_broken_pipe() -> OnBrokenPipe {
            OnBrokenPipe::BackwardsCompatible
        }
    };
unsafe extern "Rust" {
    /// Foo
    #[unstable(feature = "on_broken_pipe", issue = "150588")]
    #[rustc_eii_extern_item]
    pub safe fn on_broken_pipe()
    -> OnBrokenPipe;
}
/// Foo
#[unstable(feature = "on_broken_pipe", issue = "150588")]
#[rustc_builtin_macro(eii_shared_macro)]
#[eii_extern_target(on_broken_pipe)]
pub macro on_broken_pipe { () => {} }
```

Note that we also need to forward the docs, otherwise get get (fatal) warnings like these:

```
warning: missing documentation for an attribute macro
    --> library/std/src/io/mod.rs:2269:1
```

r? @jdonszelmann

Tracking issues:
- rust-lang#125418
- rust-lang#150588

### What about a test?

rust-lang#150591 will prevent regressions once it lands since it does not build without this fix. I think it is overkill to add a temporary eii to std before that.
Zalathar added a commit to Zalathar/rust that referenced this pull request Jan 11, 2026
compiler: Forward attributes to eii-expanded macros

Since rust-lang#150592 is quite complicated to reason about I figured it would be good to split it up in smaller pieces that are easier to digest. Here is the attribute fix in isolation.

## The Problem

With this eii in **library/std/src/io/mod.rs**:
```rs
/// Foo
#[eii(on_broken_pipe)]
#[unstable(feature = "on_broken_pipe", issue = "150588")]
pub fn on_broken_pipe() -> OnBrokenPipe {
    OnBrokenPipe::BackwardsCompatible
}
```

you currently get this compilation error:

```
error: attribute macro has missing stability attribute
    --> library/std/src/io/mod.rs:2269:1
     |
2269 | #[eii(on_broken_pipe)]
     | ^^^^^^^^^^^^^^^^^^^^--
     | |
     | in this attribute macro expansion
     |
    ::: library/core/src/macros/mod.rs:1899:5
     |
1899 |     pub macro eii($item:item) {
     |     ------------- in this expansion of `#[eii]`
```

because with ` MAGIC_EXTRA_RUSTFLAGS=-Zunpretty=expanded ./x build library/std` we can see that a pub item in the expanded code is indeed missing that attribute:

```rs
const _: () =
    {
        #[on_broken_pipe]
        fn on_broken_pipe() -> OnBrokenPipe {
            OnBrokenPipe::BackwardsCompatible
        }
    };
unsafe extern "Rust" {
    /// Foo
    #[unstable(feature = "on_broken_pipe", issue = "150588")]
    #[rustc_eii_extern_item]
    pub safe fn on_broken_pipe()
    -> OnBrokenPipe;
}
#[rustc_builtin_macro(eii_shared_macro)]
#[eii_extern_target(on_broken_pipe)]
pub macro on_broken_pipe { () => {} }
```

## The Solution

With the fix, that error goes away because we get this expanded code instead:

```rs
const _: () =
    {
        #[on_broken_pipe]
        fn on_broken_pipe() -> OnBrokenPipe {
            OnBrokenPipe::BackwardsCompatible
        }
    };
unsafe extern "Rust" {
    /// Foo
    #[unstable(feature = "on_broken_pipe", issue = "150588")]
    #[rustc_eii_extern_item]
    pub safe fn on_broken_pipe()
    -> OnBrokenPipe;
}
/// Foo
#[unstable(feature = "on_broken_pipe", issue = "150588")]
#[rustc_builtin_macro(eii_shared_macro)]
#[eii_extern_target(on_broken_pipe)]
pub macro on_broken_pipe { () => {} }
```

Note that we also need to forward the docs, otherwise get get (fatal) warnings like these:

```
warning: missing documentation for an attribute macro
    --> library/std/src/io/mod.rs:2269:1
```

r? @jdonszelmann

Tracking issues:
- rust-lang#125418
- rust-lang#150588

### What about a test?

rust-lang#150591 will prevent regressions once it lands since it does not build without this fix. I think it is overkill to add a temporary eii to std before that.
rust-timer added a commit that referenced this pull request Jan 11, 2026
Rollup merge of #150913 - eii-macro-attrs, r=jdonszelmann

compiler: Forward attributes to eii-expanded macros

Since #150592 is quite complicated to reason about I figured it would be good to split it up in smaller pieces that are easier to digest. Here is the attribute fix in isolation.

## The Problem

With this eii in **library/std/src/io/mod.rs**:
```rs
/// Foo
#[eii(on_broken_pipe)]
#[unstable(feature = "on_broken_pipe", issue = "150588")]
pub fn on_broken_pipe() -> OnBrokenPipe {
    OnBrokenPipe::BackwardsCompatible
}
```

you currently get this compilation error:

```
error: attribute macro has missing stability attribute
    --> library/std/src/io/mod.rs:2269:1
     |
2269 | #[eii(on_broken_pipe)]
     | ^^^^^^^^^^^^^^^^^^^^--
     | |
     | in this attribute macro expansion
     |
    ::: library/core/src/macros/mod.rs:1899:5
     |
1899 |     pub macro eii($item:item) {
     |     ------------- in this expansion of `#[eii]`
```

because with ` MAGIC_EXTRA_RUSTFLAGS=-Zunpretty=expanded ./x build library/std` we can see that a pub item in the expanded code is indeed missing that attribute:

```rs
const _: () =
    {
        #[on_broken_pipe]
        fn on_broken_pipe() -> OnBrokenPipe {
            OnBrokenPipe::BackwardsCompatible
        }
    };
unsafe extern "Rust" {
    /// Foo
    #[unstable(feature = "on_broken_pipe", issue = "150588")]
    #[rustc_eii_extern_item]
    pub safe fn on_broken_pipe()
    -> OnBrokenPipe;
}
#[rustc_builtin_macro(eii_shared_macro)]
#[eii_extern_target(on_broken_pipe)]
pub macro on_broken_pipe { () => {} }
```

## The Solution

With the fix, that error goes away because we get this expanded code instead:

```rs
const _: () =
    {
        #[on_broken_pipe]
        fn on_broken_pipe() -> OnBrokenPipe {
            OnBrokenPipe::BackwardsCompatible
        }
    };
unsafe extern "Rust" {
    /// Foo
    #[unstable(feature = "on_broken_pipe", issue = "150588")]
    #[rustc_eii_extern_item]
    pub safe fn on_broken_pipe()
    -> OnBrokenPipe;
}
/// Foo
#[unstable(feature = "on_broken_pipe", issue = "150588")]
#[rustc_builtin_macro(eii_shared_macro)]
#[eii_extern_target(on_broken_pipe)]
pub macro on_broken_pipe { () => {} }
```

Note that we also need to forward the docs, otherwise get get (fatal) warnings like these:

```
warning: missing documentation for an attribute macro
    --> library/std/src/io/mod.rs:2269:1
```

r? @jdonszelmann

Tracking issues:
- #125418
- #150588

### What about a test?

#150591 will prevent regressions once it lands since it does not build without this fix. I think it is overkill to add a temporary eii to std before that.
@Enselic
Copy link
Member Author

Enselic commented Jan 13, 2026

@Enselic Enselic closed this Jan 13, 2026
@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jan 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

F-extern_item_impls `#![feature(extern_item_impls)]` T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hundreds of missing stability attribute errors with trivial Externally Implementable Item (eii) function in library/std

5 participants